<?php Yii::app()->clientScript->registerCoreScript("jquery")?>
<?php Yii::app()->clientScript->registerScriptFile('/js/facebox.js')?>
<?php Yii::app()->clientScript->registerScriptFile('/js/highcharts.js')?>

<div id="store">
	<div id="menu">
		<h2><a href="<?php echo $this->createUrl('store/index', array('name'=>$store['name'])) ?>"><img src="<?php echo Yii::app()->getBaseUrl(true); ?>/images/marcas/<?php echo $store['id'] ?>/<?php echo $store['logo_url'] ?>" class="logo"/></a></h2>
	</div>
	<div id="balance">
		<div id="price">
			<a href="<?php echo $this->createUrl('state/price', array('id'=>$store['id'])); ?>" rel="facebox">
				<h4>Precio por visita</h4>
				<p>S/. <?php echo $store['new_visit_price'] ?></p>
			</a>
		</div>
		<h2>Pagos (<?php echo CHtml::link('Agregar', array('state/fee','store_id'=>$store['id']), array('rel'=>'facebox')); ?>)</h2>
		<p>Cuenta en S/.: <strong><?php echo Yii::app()->params['bankAccount'] ?></strong> (BCP).</p>
		<p>
		<blockquote style="margin-right:220px">
			RECOMENDACION: Realice sus pagos via <strong>Agente BCP</strong>. Para evitar la comisión de S/. 7.00 (a cuenta del cliente).
		</blockquote>
		</p>
		<table id="tpagos" border="0" cellspacing="2" cellpadding="3">
			<tr>
				<th>Fecha</th>
				<th>Hora</th>
				<th>Codigo</th>
				<th>Monto (S/.)</th>
				<th>Operación</th>
			</tr>
			<?php foreach ($fees as $fee): ?>
			<tr id="tr<?php echo $fee['id'] ?>">
				<td><?php echo Yii::app()->dateFormatter->format('yyyy-MM-dd',$fee['date_time']) ?></td>
				<td><?php echo Yii::app()->dateFormatter->format('HH:mm:ss',$fee['date_time']) ?></td>
				<td><?php echo $fee['code'] ?></td>
				<td style="text-align:right"><?php echo $fee['amount'] ?></td>
				<td style="text-align:center"><a id="a<?php echo $fee['id'] ?>" href="#">Eliminar</a></td>
			</tr>
			<script type="text/javascript" charset="utf-8">
				$("#a<?php echo $fee['id'] ?>").click(function(){
					$.get("<?php echo $this->createUrl('state/delete', array('id'=>$fee['id'])) ?>", function(data){
						$("#tr<?php echo $fee['id'] ?>").fadeOut(500);
					});
				});
			</script>
			<?php endforeach ?>
		</table>
		<h2>Balance</h2>
		<table id="tbalance"  border="0" cellspacing="2" cellpadding="3">
			<tr>
				<th>Fecha</th>
				<th>Nro. Visitas</th>
				<th>PU Visita (S/.)</th>
				<th>Depositos (S/.)</th>
				<th>Saldo (S/.)</th>
			</tr>
			<?php foreach ($account as $item): ?>
			<tr>
				<td><?php echo Yii::app()->dateFormatter->format('yyyy-MM-dd',$item['date']) ?></td>
				<td style="text-align:right"><?php echo $item['visits_number'] ?></td>
				<td style="text-align:right"><?php echo $item['visit_price'] ?></td>
				<td style="text-align:right"><?php echo $item['fee_amount'] ?></td>
				<td style="text-align:right"><?php echo $item['balance'] ?></td>
			</tr>
			<?php endforeach ?>
		</table>
	</div>
	<div class="clear"></div>
</div>
<script type="text/javascript" charset="utf-8">
	jQuery(document).ready(function(){
		$('#key').focus();
		$('a[rel*=facebox]').facebox();
		$('#tpagos tr').each(function(i, item){
			if(i%2==1)
				$(this).addClass("odd");
		});
		$('#tbalance tr').each(function(i, item){
			if(i%2==1)
				$(this).addClass("odd");
		});
	});
</script>